<?
require_once("../config/dbconn.php");require_once("../config/powercls.php");require_once("../config/pagecls.php");

if($action=='del'){
	$sql="select id from {$db_prefix}newfl where find_in_set('$id',path)>0";
	$rs=$db->get_one($sql);
	if ($rs['id']){
		echo "<script>alert('有下级分类不能删除');history.back();</script>";exit();
	}
	$sql="delete from {$db_prefix}newfl where id='$id'";
	$db->query($sql);
	echo "<script>location.href='category.php';</script>";exit();
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
<table width="100%" border="0">
  <tr>
    <td>编号</td>
    <td>分类名</td>
    <td>操作</td>
  </tr>
  <?
  $query='';
  if ($action=='query'){
  	
  }
  $sql="select count(id) as c  from {$db_prefix}newfl where 1";
  if ($query!='') $sql.=$query;
  $rs=$db->get_one($sql);
  $page=new pagecls(20,intval($rs['c']));
  $sql="select * from {$db_prefix}newfl where 1";
  if ($query!='') $sql.=$query;
  $sql.=" order by orders asc limit {$page->pastnum},{$page->pagesize}";
  $result=$db->query($sql);
  while($rs=$db->fetch_array($result)){
  ?>
  <tr>
    <td><?=$rs['id']?></td>
    <td><?=str_repeat("---",$rs['depth']-1)?><?=$rs['flname']?></td>
    <td><a href="categoryadd.php?fid=<?=$rs['id']?>&pageno=<?=$page->pageno?>">添加</a>|<a href="?action=del&id=<?=$rs['id']?>&pageno=<?=$page->pageno?>">删除</a></td>
  </tr>
  <?
  }
  $db->free_result($result);
  ?>
  <tr>
    <td colspan="3">每页<?=$page->pagesize?>条 第<?=$page->pageno?>/<?=$page->pagenum?>页 共<?=$page->recnum?>条 <a href='?<?=$page->url?>1'>首页</a>   <a href='?<?=$page->url.($page->pageno-1)?>'>上一页</a>  <a href='?<?=$page->url.($page->pageno+1)?>'>下一页</a>   <a href='?<?=$page->url.$page->pagenum?>'>尾页</a></td>
  </tr>
</table>

<a href="categoryadd.php">添加一级分类</a>
</body>
</html>
